package demo.base.connect;

import com.alibaba.fastjson.JSON;

public class OrderAllInfo extends Order {
    private String date;
    private String address;
    private String product;
    private double sum;

    public OrderAllInfo() {
        super("test");
    }

    public OrderAllInfo(String orderId, String date, String address, String product, double sum) {
        super(orderId);
        this.date = date;
        this.address = address;
        this.product = product;
        this.sum = sum;
    }

    public OrderAllInfo(OrderAddress add, OrderDetail detail) {
        super(add.getOrderId());
        this.date = add.getDate();
        this.address = add.getAddress();
        this.product = detail.getProduct();
        this.sum = detail.getSum();
    }

    @Override
    public OrderAllInfo collect(String o1, String o2) {
        System.out.println("o1:" + o1);
        System.out.println("o2: " + o2);
        OrderAddress orderAddress = JSON.parseObject(o1, OrderAddress.class);
        OrderDetail orderDetail = JSON.parseObject(o2, OrderDetail.class);

        return new OrderAllInfo(orderAddress, orderDetail);
    }

    @Override
    public String toString() {
        return "OrderAllInfo{"
                + "date='"
                + date
                + '\''
                + ", address='"
                + address
                + '\''
                + ", product='"
                + product
                + '\''
                + ", sum="
                + sum
                + '}';
    }
}
